package liangtWorkSpace.vaild;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController extends BaseController {

    @Autowired
    private IUserService service;

    @PostMapping("/add")
    public BaseResult userAdd(@RequestBody @Validated({ValidType.Add.class}) User user, BindingResult bindingResult) {
        BaseResult baseResult = BaseResult.successResult();
        service.insert(user);
        return baseResult;
    }

    @PostMapping("/update")
    public BaseResult userUpdate(@RequestBody @Validated({ValidType.Update.class}) User user, BindingResult bindingResult){
        BaseResult baseResult = BaseResult.successResult();
        service.updateById(user);
        return baseResult;
    }
    
  }